package com.jyh.homework.homework5;

import java.util.ArrayList;

public class TestStudent{
    public static void main(String[] args) {
        ArrayList list=new ArrayList();
        list.add(new Student("蔡徐坤",18,90));
        list.add(new Student("王子异",19,56));
        list.add(new Student("丁真",20,70));
        list.add(new Student("王源",21,60));
        list.add(new Student("展亚鹏",22,65));
        list.add(new Student("铁山靠",23,75));
        list.add(new Student("赵铁柱",24,85));
        list.add(new Student("王大锤",25,95));
        list.add(new Student("鸡太美",26,99));
        list.add(new Student("你干嘛",27,55));

        MaxScore(list);
        allScore(list);
        allAvg(list);
        no(list);
    }
    public static void MaxScore(ArrayList<Student> student){
        Student ScoreMax=student.get(0);
        for (int i = 0; i < student.size(); i++) {
            if (ScoreMax.getScore()<student.get(i).getScore()){
                ScoreMax=student.get(i);
            }
        }
        System.out.println(ScoreMax);
    }

    public  static  void allScore(ArrayList<Student> student){
        Integer sum=0;
        for (int i = 0; i < student.size(); i++) {
            sum=sum+student.get(i).getScore();
        }
        System.out.println("10个学生的总成绩为:"+sum);
    }

    public static void allAvg(ArrayList<Student> student){
        Integer sum=0;
        Integer count=0;
        for (int i = 0; i < student.size(); i++) {
            sum=sum+student.get(i).getScore();
            count++;
        }
        System.out.println(count+"个学生的平均分为："+(sum/count));
    }

    public static void no(ArrayList<Student> student){
        Integer count=0;
        for (int i = 0; i < student.size(); i++) {
            if (student.get(i).getScore()<60){
                System.out.println("不及格的学员信息：");
                System.out.println("姓名\t年龄\t成绩");
                System.out.println(student.get(i).getName()+" "+student.get(i).getAge()+"\t"+student.get(i).getScore());
                count++;
            }
        }
        System.out.println("不及格的学员数量为："+count+"个");
    }
}
